using System;

namespace Blog.Net
{
	/// <summary>
	/// A class that holds static methods to check query string data
	/// </summary>
	public class QueryStringChecker
	{
		/// <summary>
		/// Default constructor is private therefore no instances can be created
		/// </summary>
		private QueryStringChecker()
		{
			// cannot instantiate
			// all members are static
		}
		/// <summary>
		/// Check to see that your Query String is a positive number within int value
		/// As well as checking to see that the number has only 9 digits
		/// </summary>
		/// <param name="qString"></param>
		/// <returns></returns>
		public static bool CheckPositiveInteger(string qString)
		{
			bool isNumber = true;	
			if(qString.Length < 10 && qString.Length > 0)
			{			
				for(int i = 0; i < qString.Length; i++)
				{
					if(!char.IsNumber(qString, i))
					{
						isNumber = false;
						break;
					}
				}
			}
			else
				isNumber = false;
			return isNumber;
		}

		/// <summary>
		/// Check that it only contains charaters
		/// </summary>
		/// <param name="qString"></param>
		/// <returns></returns>
		public static bool CheckString(string qString)
		{
			bool isWord = true;
			if(qString.Length == 0) 
			{
				isWord = false;
				return isWord;
			}
			for(int i = 0; i < qString.Length; i++)
			{
				if(!char.IsLetter(qString, i))
				{
					isWord = false;
					break;
				}
			}
			return isWord;
		}
	}
}
